<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Home\Controller;
use OT\DataDictionary;

/**
 * 前台首页控制器
 * 主要获取首页聚合数据
 */
class IndexController extends HomeController {
    public $document;
    public $category;
    public function _initialize()
    {
        parent::_initialize();
        $this->document=D("document");
        $this->category=D("Category");
    }
	/*系统首页*/
    public function index(){
        $meta=array(
            'meta_title'=>C("WEB_SITE_TITLE"),
            'keywords'  =>C("WEB_SITE_KEYWORD"),
            'description'=>C("WEB_SITE_DESCRIPTION"),
            'template_index'=>"Index/index",
        );
        //print_r(C("WEB_SITE_TITLE"));exit;
        $this->assign("meta",$meta);
        /*首页大图*/
        $banner_list=$this->document->lists(146);
        foreach ($banner_list as $key=>$val){
            $banner_list[$key]=$this->document->detail($val['id']);
        }
        $this->assign("banner_list",$banner_list);
        /*通知公告*/
        $notification=$this->document->sub_document(1296,true,5);
        $this->assign("notification",$notification);
        /*核心技术*/
        $technology = $this->document->lists(159,3);
        $this->assign("technology",$technology);
        /*关于我们*/
        $about = $this->document->detail(1128);
        $this->assign("about",$about);
        /*典型案例*/
        $cases_cate = $this->document->lists(170,3);
        $this->assign("cases_cate",$cases_cate);
        $cases_list['list1'] =$this->document->sub_document($cases_cate[0]['id'],true);
        $cases_list['list2'] =$this->document->sub_document($cases_cate[1]['id'],true);
        $cases_list['list3'] =$this->document->sub_document($cases_cate[2]['id'],true);
        $this->assign("cases_list",$cases_list);
        /*新闻案例*/
        $news_list =$this->document->sub_document(1293,true,4);
        $this->assign("news_list",$news_list);
        $this->display();
    }
    public function cases(){
        if(IS_AJAX){
            $id=I("post.id",0,"int");
            $cases_list=$this->document->sub_document($id,true);
            foreach ($cases_list as $key=>$val){
                $cases_list[$key]['img']=get_cover($val['cover_id'],'path');
            }
            $this->ajaxReturn($cases_list);exit;
        }

    }

}